$(function($) {
  // 你可以在这里继续使用$作为别名...
  
  //$("i.i_tree_checkbox").on("click", function(){
  //  i_checkbox_toggle(this);
  //});

  //$("i.i_tree_expan").addClass("visibility_hidden");
  //$("i.i_tree_file").addClass("display_none");
  //$(".pop_contents_tree ul.treeview").addClass("tree_ul_display_none");
  //$(".pop_contents_tree ul.tree_root").removeClass("tree_ul_display_none");
  
    //onloadFun();//滚动条

    showJBoxs();
    showTips();//tips

    if (getCookie("tips") * 1 != 1) {
        setTimeout(function () { userGuide(); }, 2000);
        setCookie("tips", "1");
    } 
});
function showJBoxs() {
    showJBox("#tabs_btn_models", "\u6a21\u578b\u5217\u8868")
    showJBox("#tabs_btn_tree", "\u6a21\u578b\u7ed3\u6784\u6811")
    showJBox("#tabs_btn_attrs", "\u5c5e\u6027")
    showJBox("#tabs_btn_back", "\u9000\u51fa")
    showJBox("#tabs_btn_help", "\u5e2e\u52a9")
}
function showJBox(id,title) {
    new jBox('Mouse', {
        attach: id,
        position: { x: 'center', y: 'bottom' },
        content: title
    });
}

var indexold = -1;

function toggleTabs(ele, index) {
    if (index == 0) {
        window.location.href = "/Home/ModelList"; return;
    }
    if (index == 4) {
        window.open("/User/help"); return;
    }
    var btn_tabs = $(".btn_tabs");
    var pop_box = $($(ele).parents(".tabs_btn")[0]).next(".pop_box");

    if ($(pop_box).css("display")=="none") {
        //$(pop_box).removeClass("display_none");
        $(btn_tabs).css("height", "90%");
        $(pop_box).css("height", "95%");        
        $(pop_box).animate({opacity: 'toggle' }, "fast");
    }
    else if (indexold == index) {
        //$(pop_box).addClass("display_none");
        $(pop_box).animate({opacity: 'toggle' }, "fast", function () {
            $(pop_box).css("height", "0");
            $(btn_tabs).css("height", "auto")
        });
    }
    indexold = index;
    var arrow = $(".pop_box .arrow");
    $(arrow).removeClass("arrow0");
	$(arrow).removeClass("arrow1");
	$(arrow).removeClass("arrow2");
	$(arrow).removeClass("arrow3");
	$(arrow).removeClass("arrow4");
	$(".pop_box_contents>div").addClass("display_none")
	if(index==0){
	    $(arrow).addClass("arrow0")
	    //showModelsList();
	}else if(index==1){
		$(arrow).addClass("arrow1")
		showModelsList();
	}else if(index==2){
		$(arrow).addClass("arrow2")
		showTypeList()
	} else if (index == 3) {
		$(arrow).addClass("arrow3")
		showAttrssList()
	}
	else if (index == 5) {
	    $(arrow).addClass("arrow4");
	    showTreeList();
	    
	}
	showTips();//tips
}
function showModelsList(){
	$(".pop_box_contents .pop_contents_models").removeClass("display_none")
	$(".pop_box_contents .pop_contents_models").insertAfter(".pop_box_contents>div:last-of-type");
}
function showTreeList(){
	$(".pop_box_contents .pop_contents_tree").removeClass("display_none")
	$(".pop_box_contents .pop_contents_tree").insertAfter(".pop_box_contents>div:last-of-type");
}
function showAttrssList(){
	$(".pop_box_contents .pop_contents_attrs").removeClass("display_none")
	$(".pop_box_contents .pop_contents_attrs").insertAfter(".pop_box_contents>div:last-of-type");
}

function showTypeList()
{
    $(".pop_box_contents .pop_contents_type").removeClass("display_none")
    $(".pop_box_contents .pop_contents_type").insertAfter(".pop_box_contents>div:last-of-type");
}





function onloadFun() {
//	if (!$.browser.webkit) {
	$('body').addClass('dark');
				
	$.mCustomScrollbar.defaults.scrollButtons.enable=true; //enable scrolling buttons by default
	$.mCustomScrollbar.defaults.axis="y"; //enable 2 axis scrollbars by default
					
	$(".container").mCustomScrollbar({theme:"dark"});
					
//					$(".class_moz").removeClass("scrollbar");
//					$(".class_moz").removeClass("style-7");
//					$(".class_moz").removeClass("force-overflow");
//	}

	//if ((navigator.userAgent.indexOf('MSIE') >= 0) 
	//    && (navigator.userAgent.indexOf('Opera') < 0)){
	//    $(".check_slider").css("top","-24px");
    //}
	if (isFirefox = navigator.userAgent.indexOf("Firefox") > 0) {
		$(".pop_contents_models ul li").css("position", "relative");
		$(".pop_contents_models ul li span.checkbox").css({ "position": "relative"});
	}
	showTips();
}
function onloadFun2() {
    $('body').addClass('dark');

    $.mCustomScrollbar.defaults.scrollButtons.enable = true; //enable scrolling buttons by default
    $.mCustomScrollbar.defaults.axis = "y"; //enable 2 axis scrollbars by default

    $(".container_table").mCustomScrollbar({ theme: "dark" });
    //$("#attrprop").mCustomScrollbar({ theme: "dark" });
    $(".container_table").mCustomScrollbar("scrollTo", "top");
    showTips();
}
function showTips(){
    tips(".pop_box_contents ul li label.model_title");
    tips(".pop_box_contents ul li .tree_leave");
    tips(".pop_box_contents table tr");
}
function tips(ele) {
        $(ele).simpletooltip({
            position: 'bottom-right',
            border_color: 'rgba(90, 164, 247, 1)',
            color: '#FFFFFF',
            background_color: 'rgba(90, 164, 247, 1)',
            border_width: 4
        });
}
/*
 * 用户引导
 */
function userGuide() {
    // Set up tour
    $('body').pagewalkthrough({
        name: 'introduction',
        steps: [
        {
            popup: { content: '#walkthrough-1', type: 'modal' }
        }, {
            wrapper: '#tabs_btn_models', popup: { content: '#walkthrough-2', type: 'tooltip', position: 'right' }
        }, {
            wrapper: '#tabs_btn_tree', popup: { content: '#walkthrough-3', type: 'tooltip', position: 'right' }
        }, {
            wrapper: '#tabs_btn_attrs', popup: { content: '#walkthrough-4', type: 'tooltip', position: 'right' }
        }, {
            wrapper: '#tabnew .tabcontent', popup: { content: '#walkthrough-5', type: 'tooltip', position: 'bottom' }
        }, {
            wrapper: '#tabs_btn_help', popup: { content: '#walkthrough-6', type: 'tooltip', position: 'left' }
        }, {
            wrapper: '#tabs_btn_back', popup: { content: '#walkthrough-7', type: 'tooltip', position: 'left' }
        }]
    });
    // Show the tour
    $('body').pagewalkthrough('show'); 
}